package a.h;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Collection;

class yd
  extends JPanel
{
  private int a = 16;
  private int b = 16;
  private int c = 2;
  private int d;
  private JButton e;
  private ab f;
  private od g;
  private Color h;
  private Collection i;
  private final boolean j;
  private final boolean k;
  
  public yd(od paramod)
  {
    this(paramod, paramod.a(), true, true);
  }
  
  public yd(od paramod, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
  {
    this.k = paramBoolean1;
    this.i = new ArrayList();
    this.j = paramBoolean2;
    this.e = a();
    this.g = paramod;
    this.d = paramInt;
    a_ locala_ = new a_();
    addMouseMotionListener(locala_);
    addMouseListener(locala_);
  }
  
  private JButton a()
  {
    this.f = new ab(null);
    JButton localJButton = new JButton(bc.a(this.f.a(), this.k, this.j), this.f);
    localJButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    localJButton.setText(null);
    localJButton.setFocusPainted(false);
    Dimension localDimension = localJButton.getMinimumSize();
    this.a = localDimension.height;
    this.b = localDimension.width;
    return localJButton;
  }
  
  public int c()
  {
    return this.d;
  }
  
  public void a(int paramInt)
  {
    int m = this.d;
    this.d = paramInt;
    firePropertyChange("columnCount", m, paramInt);
  }
  
  protected void paintComponent(Graphics paramGraphics)
  {
    int i2 = ec.t;
    boolean bool = ec.s;
    if (i2 == 0)
    {
      if (isOpaque())
      {
        localObject = paramGraphics.getClipBounds();
        paramGraphics.setColor(getBackground());
        paramGraphics.fillRect(((Rectangle)localObject).x, ((Rectangle)localObject).y, ((Rectangle)localObject).width, ((Rectangle)localObject).height);
      }
      super.paintComponent(paramGraphics);
    }
    Object localObject = getInsets();
    Rectangle localRectangle = new Rectangle(((Insets)localObject).top, ((Insets)localObject).left, this.b, this.a);
    localRectangle.x = ((Insets)localObject).left;
    localRectangle.y = (((Insets)localObject).top - this.a - this.c);
    int m = e().getSize();
    int n = 0;
    label209:
    label220:
    do
    {
      if (n >= m) {
        break;
      }
      int i1 = n % this.d;
      if (i2 == 0)
      {
        if (i1 == 0)
        {
          localRectangle.x = ((Insets)localObject).left;
          if (i2 != 0) {
            break label220;
          }
          localRectangle.y += this.a + this.c;
        }
      }
      else {
        if (!bool) {
          break label209;
        }
      }
      localRectangle.x += this.b + this.c;
      Color localColor = (Color)e().getElementAt(n);
      a(paramGraphics, localRectangle, localColor, false, localColor == this.h);
      n++;
    } while (!bool);
  }
  
  protected void a(Graphics paramGraphics, Rectangle paramRectangle, Color paramColor, boolean paramBoolean1, boolean paramBoolean2)
  {
    if (paramBoolean2)
    {
      Color localColor = getBackground().brighter().brighter();
      paramGraphics.setColor(localColor);
      paramGraphics.fillRect(paramRectangle.x, paramRectangle.y, paramRectangle.width, paramRectangle.height);
      this.e.setBackground(localColor);
      if (ec.t != 0) {
        break label77;
      }
      if (!ec.s) {}
    }
    else
    {
      this.e.setBackground(getBackground());
    }
    if (paramBoolean1)
    {
      label77:
      paramGraphics.setColor(getForeground());
      paramGraphics.drawRect(paramRectangle.x, paramRectangle.y, paramRectangle.width, paramRectangle.height);
    }
    this.f.a(paramColor);
    SwingUtilities.paintComponent(paramGraphics, this.e, this, paramRectangle.x + 2, paramRectangle.y + 2, paramRectangle.width - 3, paramRectangle.height - 3);
  }
  
  public Dimension getMinimumSize()
  {
    Insets localInsets = getInsets();
    Dimension localDimension = new Dimension(localInsets.left + localInsets.right, localInsets.top + localInsets.bottom);
    int m = (int)Math.ceil(e().getSize() / this.d);
    localDimension.height += m * this.a;
    localDimension.width += this.d * this.b;
    if (ec.t == 0) {
      if (m > 1) {
        localDimension.height += (m - 1) * this.c;
      }
    }
    if (this.d > 0) {
      localDimension.width += (this.d - 1) * this.c;
    }
    return localDimension;
  }
  
  public Dimension getPreferredSize()
  {
    return getMinimumSize();
  }
  
  public ComboBoxModel e()
  {
    return this.g;
  }
  
  Color a(int paramInt1, int paramInt2)
  {
    int i1 = ec.t;
    boolean bool = ec.s;
    Insets localInsets = getInsets();
    Rectangle localRectangle = new Rectangle(localInsets.top, localInsets.left, this.b, this.a);
    localRectangle.x = localInsets.left;
    localRectangle.y = (localInsets.top - this.a - this.c);
    int m = 0;
    label159:
    label166:
    do
    {
      if (m >= this.g.getSize()) {
        break;
      }
      int n = m % this.d;
      if (i1 == 0)
      {
        if (n == 0)
        {
          localRectangle.x = localInsets.left;
          localRectangle.y += this.a + this.c;
        }
      }
      else
      {
        if (i1 != 0) {
          break label166;
        }
        if (!bool) {
          break label159;
        }
      }
      localRectangle.x += this.b + this.c;
      if (i1 == 0)
      {
        if (localRectangle.contains(paramInt1, paramInt2)) {
          return (Color)e().getElementAt(m);
        }
        m++;
      }
    } while (!bool);
    return null;
  }
  
  public void a(ActionListener paramActionListener)
  {
    this.i.add(paramActionListener);
  }
  
  protected void f()
  {
    boolean bool = ec.s;
    if (!this.i.isEmpty())
    {
      ActionEvent localActionEvent = new ActionEvent(this, 42, "");
      ActionListener[] arrayOfActionListener = new ActionListener[this.i.size()];
      this.i.toArray(arrayOfActionListener);
      int m = 0;
      do
      {
        if (m >= arrayOfActionListener.length) {
          break;
        }
        arrayOfActionListener[m].actionPerformed(localActionEvent);
        m++;
      } while (!bool);
    }
  }
  
  class a_
    extends MouseAdapter
    implements MouseMotionListener
  {
    a_() {}
    
    public void mouseMoved(MouseEvent paramMouseEvent)
    {
      yd.this.h = yd.this.a(paramMouseEvent.getX(), paramMouseEvent.getY());
      yd.this.f.a(yd.this.h);
      if (ec.t == 0) {}
      yd.this.setToolTipText(yd.this.h == null ? null : bc.a(yd.this.h, yd.this.k, yd.this.j));
      yd.this.repaint();
    }
    
    public void mouseDragged(MouseEvent paramMouseEvent) {}
    
    public void mouseClicked(MouseEvent paramMouseEvent)
    {
      yd.this.e().setSelectedItem(yd.this.a(paramMouseEvent.getX(), paramMouseEvent.getY()));
      yd.this.f();
    }
    
    public void mouseExited(MouseEvent paramMouseEvent)
    {
      yd.this.h = null;
      yd.this.repaint();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.h.yd

 * JD-Core Version:    0.7.0.1

 */